package com.xtj.direct;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.xtj.utils.RabbitMQUtils;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

<<<<<<< HEAD
//routing订阅 (direct)直连模型 (消费者监控通道，发布立即接受)
=======
//routing订阅 (direct)直连模型
>>>>>>> 59035a80ec862f1dc9a1ab19024377ee03a067a8
public class Provider {
    public static void main(String[] args) throws IOException {
        //获取连接对象
        Connection connection = RabbitMQUtils.getConnection();
        //获取连接通道对象
        Channel channel = connection.createChannel();
        //通过声明交换机 参数1:交换机名称  参数2: direct 路由模式
        channel.exchangeDeclare("logs_direct","direct");
        //发生消息
        String routingkey = "error";
        channel.basicPublish("logs_direct",routingkey,null,("这是direct模型发布的基于route key：["+routingkey+"]发布的信息").getBytes(StandardCharsets.UTF_8));

        //关闭资源
        RabbitMQUtils.closeConnectionAndChanel(channel,connection);

    }
}
